import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;


public class ParseCotacao {

	public static void main(String[] args)
	{
		File file = new File("/home/janilton/popupHistorico.html");
		try
		{
			BufferedReader buffer = new BufferedReader(new FileReader(file));
			String read = buffer.readLine();
			StringBuilder text = new StringBuilder();
			while (read != null)
			{
				text.append(read);
				read = buffer.readLine();
			}
			//System.out.println(text);
			
			//String html = text.toString();
			String html = "sssssssssssssssssds sdsd<table width='100%' border='0' cellpadding='0' cellspacing='0'><tr class='tblHeader'>	<td colspan='3'><img src='imgs/titHistoricoCotas.gif' width='106' height='21' /></td></tr><tr>	<td align='left' class='tblInfo' style='border-left:1px solid #9ea3ca; text-align:left;font-weight:bold'>Data   &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;       |</td>	<td align='left' class='tblInfo' style='text-align:left;font-weight:bold'>Cota (R$)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    |</td>	<td align='left' class='tblInfo' style='border-right:1px solid #9ea3ca; text-align:left;font-weight:bold'>Pat. Liquido (R$)</td></tr><tr>	<td align='left' class='tblInfo' style='border-left:1px solid #9ea3ca; text-align:left'>30/07/07</td>	<td align='left' class='tblInfo'>1,7517048</td>	<td align='left' class='tblInfo' style='border-right:1px solid #9ea3ca; text-align:left'>417,62M</td></tr></table>sbdvnsbdmnsvbnmdvs";
			System.out.println(getTableHistoricoCotas(html));
			
			
			
		} 
		catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
	
	private static String getTableHistoricoCotas(String html)
	{
		String table = "";
		int iStartImg = html.indexOf("titHistoricoCotas.gif");
		if (iStartImg > -1) {
			int iStartTable = html.lastIndexOf("<table", iStartImg);
			int iEndTable = html.indexOf("</table>", iStartImg);
			if (iStartTable > -1) 
			{
				table = html.substring(iStartTable, iEndTable+8);
			}	
		}
		
		return table;
	}

/*	http://www.google.com/ig/directory?source=gapi&num=24&url=http://sav74sac.googlepages.com/portfolio.xml

		http://www.google.com/ig/directory?root=/ig&dpos=top&num=24&url=http://www.googlewidgets.net/commodities/commodities.xml

		javascript:OpenPopup('http://clubes.gerafuturo.com.br/clubinv/v2/detalhes.asp?ativo=248','620','450','yes')

		http://clubes.gerafuturo.com.br/clubinv/v2/popupHistorico.asp?ativo=248

		http://clubes.gerafuturo.com.br/clubinv/v2/popupHistorico.asp?ativo=248&TipoBusca=1&DataIni=30/07/2007&DataFim=30/07/2007

		http://gerafuturo-gadget.googlecode.com/svn

		http://clubes.gerafuturo.com.br/clubinv/v2/popupHistorico.asp?ativo=248&TipoBusca=1&DataIni=28/07/2007&DataFim=30/07/2007
	*/
	
}
